#登录业务

# 导入该业务有关的N个页面类
from page.page_index import PageIndex
from page.page_login import PageLogin
from page.page_user import PageUser

class ServiceLogin(object):
    def __init__(self,driver,base_url):
        #接收test层传递来的driver
        self.driver=driver
        self.base_url=base_url
        #初始化和该业务有关的N个页面对象
        self.page_index=PageIndex(self.driver,self.base_url)
        self.page_login=PageLogin(self.driver,self.base_url)
        self.page_user=PageUser(self.driver,self.base_url)


    def service_login_001(self,d):
        #接收测试数据
        key=d["key"]
        zanhao=d["zanhao"]
        pwd=d["pwd"]
        yuqi=d["yuqi"]
        #完成首页UI的UI操作
        self.page_index.openUrl()
        self.page_index.click_login()
        #完成登录页UI的UI操作
        self.page_login.input_zanhao(zanhao)
        self.page_login.input_pwd(pwd)
        self.page_login.click_login()
        #完成个人中心页面UI的UI操作
        siji=self.page_user.getNicenH2TagText() #"laodon，欢迎光临"
        return yuqi == siji

    def service_login_002(self,d):
        #接收测试数据
        key=d["key"]
        zanhao=d["zanhao"]
        pwd=d["pwd"]
        yuqi=d["yuqi"]
        #完成首页UI的UI操作
        self.page_index.openUrl()
        self.page_index.click_login()
        #完成登录页UI的UI操作
        self.page_login.input_zanhao(zanhao)
        self.page_login.input_pwd(pwd)
        self.page_login.click_login()
        siji=self.page_login.getErrorTipDivText() #"账户密码错误"
        return yuqi in siji

    def service_login_003(self,d):
        #接收测试数据
        key=d["key"]
        zanhao=d["zanhao"]
        pwd=d["pwd"]
        yuqi=d["yuqi"]
        #完成首页UI的UI操作
        self.page_index.openUrl()
        self.page_index.click_login()
        #完成登录页UI的UI操作
        self.page_login.input_zanhao(zanhao)
        self.page_login.input_pwd(pwd)
        self.page_login.click_login()
        siji=self.page_login.getZanhaoEleAttrClass() #"input_text  invalid-text"
        return yuqi in siji

    def service_login_004(self,d):
        #接收测试数据
        key=d["key"]
        zanhao=d["zanhao"]
        pwd=d["pwd"]
        yuqi=d["yuqi"]
        #完成首页UI的UI操作
        self.page_index.openUrl()
        self.page_index.click_login()
        #完成登录页UI的UI操作
        self.page_login.input_zanhao(zanhao)
        self.page_login.input_pwd(pwd)
        self.page_login.click_login()
        siji=self.page_login.getPwdEleAttrClass() #"input_text  invalid-text"
        return yuqi in siji


